<template>
	<view>
		<view class="table">
			<view class="" :style="tabStyle(index)" v-for="(item, index) in tabBars" :key="index"
				@click="tabChange(index)">
				{{ item }}
			</view>
		</view>
		<view class="" v-show="tabIndex === 0">
			<view class="tip">根据国家要求规定，上门护理服务需进行身份</view>
			<view class="positive">
				<view class="left"></view>身份证正面照
			</view>
			<view class="upload" @click="idCard()" style="
          background: url(../../../static/img/iden/card.png);
          background-size: 488rpx 324rpx;
        ">
				<image :src="cardSrc" mode="aspectFit"></image>
				<image src="../../../static/img/iden/seal.png" mode="aspectFit" class="seal" v-if="num < 0"></image>
			</view>
			<view class="head"> 点击上传头像面 </view>
			<!-- 拍摄提示 -->
			<view class="" style="width: 100%; height: 532rpx; box-sizing: border-box" v-if="!cardSrc">
				<view class="positive">
					<view class="left"></view>拍摄须知
				</view>
				<view class="demo">
					<view class="demo1" v-for="(item, index) in demo1" :key="index"
						style="width: 132rpx; height: 88rpx">
						<image :src="item.src" mode="aspectFit" style="width: 132rpx; height: 88rpx"></image>

						<view class="demo2"><text :style="item.style">{{ item.judge }}</text>{{ item.txt }}</view>
					</view>
				</view>
			</view>

			<!-- 身份证上传失败显示 -->
			<view class="lose" v-else>
				<view class="loseTip">
					<view class="tanhao icon-a-qingkongpng iconfont" v-if="num > 0"></view>
					<view class="loseReason">{{
            num > 0 ? "失败原因：您的网络信号不佳" : ""
          }}</view>
				</view>
				<view class="please">
					<view class="">请联系护士小鹿客服400-880-9120</view>
					<view class="">上班时间：工作日（9:00~17:30）</view>
				</view>
			</view>

			<view class="into into1" v-if="!onData.faceJson">
				<view class="save" style="background-color: #3c8eff" @click="moveTo">下一步：人脸验证</view>
			</view>
		</view>

		<!-- 执业认证 -->
		<view class="" v-show="tabIndex === 1">
			<view class="" v-if="onData.status > 2 || onData.status < 1">
				<view class="tip">根据国家要求规定，认证护士需进行身份核实</view>
				<view class="positive">
					<view class="left"></view>护士资格证书
				</view>
				<view class="upload" @click="nurseFirst" style="
				background: url(../../../static/img/iden/zhengshu.png);
				background-size: 488rpx 324rpx;
			  ">
					<image :src="this.data1.nursePicture" mode="aspectFit"></image>
				</view>
				<view class="head"> 点击上传带章页、姓名页  </view>

				<view class="positive">
					<view class="left"></view>护士执业证书
				</view>
				<view class="time">
					<text class="name">注册有效期至：</text>
					<view class="value">
						<view class="" v-if="onData.status == 2" style="color: rgba(0, 0, 0, 0.38); text-align: right"
							@click="remind()">
							{{ onData.expirationDate }}
						</view>
						<biaofun-datetime-picker :placeholder="showPicker" v-else :start="currentDate" end="2100-10-28"
							fields="day" style="color: rgba(0, 0, 0, 0.38)" @change="changeDatetimePicker">
						</biaofun-datetime-picker>
					</view>
					<!-- <text class="iconfont right-icon">&#xe63e;</text> -->
					<image src="../../../static/icon/set-code/nav-back.png" mode=""></image>
				</view>
				<view class="zsType time" v-if="onData.status != 2">
					<text class="name">证书类型</text>
					<view class="type">
						<view :class="['type1', index == dataType ? 'type2' : '']" style="position: relative"
							v-for="(item, index) in zsType" :key="index" @click="typeChange(index)">
							{{ item }}
							<view class="dui" v-show="index == dataType">
								<image src="../../../static/img/iden/dui.png" mode=""
									style="width: 16rpx; height: 16rpx">
								</image>
							</view>
						</view>
					</view>
					<!-- <text class="iconfont right-icon">&#xe63e;</text> -->
				</view>
				<!-- 上传首页 -->
				<view class="box" v-for="(item, index) in showType" :key="index">
					<view class="upload" @click="nursePicture(item)" :style="item.bg">
						<image :src="item.src" mode="aspectFit"></image>
					</view>
					<view class="head" v-if="onData.status != 2">
						点击上传{{ item.txt }}
					</view>
				</view>
				<!-- 拍摄提示 -->
				<view class="" style="width: 100%; height: 320rpx; box-sizing: border-box">
					<view class="positive">
						<view class="left"></view>拍摄须知
					</view>
					<view class="demo">
						<view class="demo1" v-for="(item, index) in demo2" :key="index"
							style="width: 132rpx; height: 88rpx">
							<image :src="item.src" mode="aspectFit" style="width: 132rpx; height: 88rpx"></image>

							<view class="demo2"><text :style="item.style">{{ item.judge }}</text>{{ item.txt }}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 其他信息 -->
			<view class="" style="">
				<view class="positive" v-if="onData.status > 2 || onData.status < 1">
					<view class="left"></view>其他信息
				</view>
				<view class="time" v-for="(item, index) in list" :key="item.txt">
					<text class="name">{{ item.txt }}</text>
					<template v-if="index == 0">
						<input class="value other" type="text" v-model="data1.hospital" :placeholder="item.pla" />
						<image src="../../../static/icon/set-code/nav-back.png" mode="" @click="change(index)"></image>
					</template>

					<template v-else>

						<input type="text" class="value other" disabled="true" v-model="item.value"
							:placeholder="item.pla" @click="change(index)" placeholder-style="color:#999999;" />
						<image src="../../../static/icon/set-code/nav-back.png" mode="" @click="change(index)"></image>

					</template>
				</view>
				<view class="update-btn1">
					<button class="update-btn d-center" v-if="editStatus==1&&(onData.status==2||onData.status==1)"
						@click="updateInfo(nurseId)">更新职业资格证书</button>
				</view>
				<!-- 拒绝原因 -->
				<view class="" v-if="onData.subStatus==3" style="color: crimson;padding: 5%;">
					您的申请已被拒绝，请重新提交： <br>拒绝原因：{{onData.reason}} </view>
			</view>

			<!-- <picker mode="selector"  :range="itemOptions"  range-key="label" @change.stop="itemChange"  >
				<view v-if="this.popList == 4">{{serviceType}}</view>
			</picker> -->
			<uni-popup ref="popup" type="center">
				<!-- <button type="default" class="del" @click="closePopup">取消</button> -->
				<view class="pop">
					<view class="popTitle">{{ this.popTitle }}</view>
					<!-- 科室和职称弹窗 -->
					<scroll-view scroll-y="true" style="height: 442rpx; padding-left: 30rpx; box-sizing: border-box">
						<!-- 科室多选 -->
						<radio-group @change="checkboxChange" v-if="this.popList == 1">
							<label class="" v-for="(item, index) in section" :key="index"
								style="margin-top: 30rpx; display: flex">
								<view class="hosptial">
									<radio :value="item" color="#3c8eff" style="
                      transform: scale(0.7);
                      'color':#3c8eff ;
                      border-radius: 50%;
                    " />
								</view>
								<view>{{ item }}</view>
							</label>
						</radio-group>
						<!-- 职位单选 -->
						<radio-group @change="radioChange" v-if="this.popList == 2">
							<label class="" v-for="(item, index) in nurse" :key="index"
								style="margin-top: 30rpx; display: flex">
								<view>
									<radio :value="item" color="#3c8eff"
										style="transform: scale(0.7); color: #3c8eff" />
								</view>
								<view>{{ item }}</view>
							</label>
						</radio-group>
						<!-- 选择年限弹窗 -->
						<radio-group @change="yearChange" v-if="this.popList == 3">
							<label class="" v-for="(item, index) in year" :key="index"
								style="margin-top: 30rpx; display: flex">
								<view>
									<radio :value="item" color="#3c8eff"
										style="transform: scale(0.7); color: #3c8eff" />
								</view>
								<view>{{ item }}</view>
							</label>
						</radio-group>
						<!-- 选择服务类目弹窗 -->
						<view class="uni-list" style="margin-left: 140rpx" v-if="this.popList == 4">
							<checkbox-group @change="itemChange">
								<label class="uni-list-cell uni-list-cell-pd" v-for="item in itemOptions"
									:key="item.id">
									<view>
										<checkbox :value="item.value" :checked="item.checked" />{{
                      item.value
                    }}
									</view>
									<view>{{ item.name }}</view>
								</label>
							</checkbox-group>
						</view>
						<!-- 	<radio-group @change="itemChange" v-if="this.popList == 3">
							<label class="" v-for="(item, index) in itemOptions" :key="index"
								style="margin-top: 30rpx; display: flex;">
								<view>
									<radio :value="item" color="#3c8eff"
										style="transform:scale(0.7); color:#3c8eff;" />
								</view>
								<view>{{item}}</view>
							</label>
						</radio-group> -->
					</scroll-view>

					<view class="confirm">
						<view class="" @click="popDel">取消</view>
						<view class="" @click="confirm" style="border-left: 1rpx #e5e5e5 solid; color: #3c8eff">确定
						</view>
					</view>
				</view>
			</uni-popup>

			<view class="myinto" v-if="onData.status > 2 || onData.status < 1">
				<view class="font-sm flex align-center agree" style="margin-top: 57rpx">
					<checkbox-group name="" @change="checkboxChangeSure">
						<label>
							<checkbox color="#3C8EFF" style="transform: scale(0.5); color: #3c8eff" />
						</label>
					</checkbox-group>
					<text class="text-secondary bottomStyle">请仔细阅读</text>
					<text class="main-text-color bottomStyle" @click="nurseNeed()">《护士上门服务工作流程》</text>
				</view>
			</view>
			<view class="into" v-if="onData.status > 2 || onData.status < 1">
				<view class="save" @click="save(nurseId)">提交</view>
			</view>
		</view>
		<uni-confirm :show="confirmShow" title="请先在首页设置位置信息" content="" @cancel="bindBtn('cancel')"
			@confirm="bindBtn('confirm')">
		</uni-confirm>
		<view class="" v-show="tabIndex === 3">
			<!-- 上传护工证 -->
			<view class="">
				<view class="positive">
					<view class="left"></view>上传护工证
				</view>
				<view class="upload" @click="idCareCard()" style="
			  background: url(../../../static/img/iden/zhengshu.png);
			  background-size: 488rpx 324rpx;
			">
					<image :src="caregiverPicture" mode="aspectFit"></image>
					<!-- <image src="../../../static/img/iden/seal.png" mode="aspectFit" class="seal" v-if="num < 0"></image> -->
				</view>
				<view class="head"> 点击上传带章页、姓名页 </view>
			</view>
			<!-- 上传身份证 -->
			<view class="">
				<!-- 正面 -->
				<view class="positive">
					<view class="left"></view>身份证正面照
				</view>
				<view class="upload" @click="idCardBefore()" style="
			  background: url(../../../static/img/iden/card.png);
			  background-size: 488rpx 324rpx;
			">
					<image :src="cardSrcBefore" mode="aspectFit"></image>
					<!-- <image src="../../../static/img/iden/seal.png" mode="aspectFit" class="seal" v-if="num < 0"></image> -->
				</view>
				<view class="head"> 点击上传头像正面 </view>
				<!-- 反面 -->
				<view class="upload" @click="idCardBack()" style="
				  background: url(../../../static/img/iden/card.png);
				  background-size: 488rpx 324rpx; 
				">
					<image :src="cardSrcBack" mode="aspectFit"></image>
					<!-- <image src="../../../static/img/iden/seal.png" mode="aspectFit" class="seal" v-if="num < 0"></image> -->
				</view>
				<view class="head"> 点击上传头像反面 </view>
				<!-- 拍摄提示 -->
				<view class="" style="width: 100%; height: 532rpx; box-sizing: border-box" v-if="!cardSrcBack">
					<view class="positive">
						<view class="left"></view>拍摄须知
					</view>
					<view class="demo">
						<view class="demo1" v-for="(item, index) in demo1" :key="index"
							style="width: 132rpx; height: 88rpx">
							<image :src="item.src" mode="aspectFit" style="width: 132rpx; height: 88rpx"></image>

							<view class="demo2"><text :style="item.style">{{ item.judge }}</text>{{ item.txt }}</view>
						</view>
					</view>
				</view>

				<!-- 身份证上传失败显示 -->
				<view class="lose" v-else>
					<view class="loseTip">
						<view class="tanhao icon-a-qingkongpng iconfont" v-if="num > 0"></view>
						<view class="loseReason">{{
			    num > 0 ? "失败原因：您的网络信号不佳" : ""
			  }}</view>
					</view>
					<view class="please">
						<view class="">请联系护士小鹿客服400-880-9120</view>
						<view class="">上班时间：工作日（9:00~17:30）</view>
					</view>
				</view>
			</view>
			<view class="into">
				<view class="save" @click="saveCare">提交</view>
			</view>
		</view>
	</view>
</template>

<script>
	import biaofunDatetimePicker from '@/components/uni-ui/biaofun-datetime-picker/biaofun-datetime-picker.vue';
	import uniConfirm from '@/components/uni-ui/uni-confirm/uni-confirm.vue'
	import uniPopup from '../../../components/uni-ui/uni-popup/uni-popup.vue';
	import uploadImage from '@/common/js/ossutil/uploadFile.js';
	import uniNumberBox from '../../../components/uni-ui/uni-number-box/uni-number-box.vue';
	import {
		translateapp
	} from '../../../common/js/common.js'
	import {
		idCardCheck,
		faceCheck
	} from '@/apis/nurse/index.js'
	import {
		selectNurseInfoCheckById,
		nurseCheckInfo
	} from '@/apis/certificate/certification.js'
	import {
		debounce
	} from '@/common/js/throttle.js'
	import {
		requestAndroid
	} from '@/common/js/location.js'
	export default {
		components: {
			biaofunDatetimePicker,
			uniPopup,
			uniNumberBox,
			uniConfirm
		},
		data() {
			return {
				cardSrcBack: '', //身份证反面
				cardSrcBefore: "", //身份证正面
				caregiverPicture: '', //护工证
				currentDate: '',
				editStatus: 1,
				check: false,
				confirmShow: false,
				showPicker: '请选择证件截止时间',
				onType: '', //获取到的护士证书图片认证信息
				onData: {
					status: 0
				}, //判断获取到的认证信息
				bol: false, //判断身份证上传成功
				num: 0, //-1已认证 0未认证 1网络不佳
				tabIndex: 0, //tab切换判断
				tabBars: ['身份认证', '执业认证', '护工职业认证'],
				zsType: ['纸质版', '电子版'],
				cardSrc: "", //身份证正面
				showType: [], //v-for type列表
				popTitle: "", //popup title
				popList: '', //popup 选项列表判断
				popData: '', //popup 选中项
				hospital: '', //执业机构
				department: '', //科室
				position: '', //职称
				workingYears: '', //年限
				serviceTypeArr: "",
				data1: {
					department: '',
					expirationDate: '',
					homePicture: '', //首页
					hospital: '',
					infoPicture: '', //详情页
					nursePicture: '',
					orderPicture: '', //延续页
					position: '',
					workingYears: '',
					serviceType: "",
					departAddress: '',
					type: 0,
					nurseId: ''
				}, //职业认证提交内容
				dataType: 0,
				itemOptions: [{
					id: 6,
					value: '上门护理',
					label: '上门护理',
					checked: true
				}, {
					id: 2,
					value: '就医陪诊',
					label: '就医陪诊',
					checked: true
				}, {
					id: 4,
					value: '儿科护理',
					label: '儿科护理',
					checked: true
				}, {
					id: 8,
					value: '核酸检测',
					label: '核酸检测',
					checked: true
				}, {
					id: 3,
					value: '居家康复',
					label: '居家康复'
				}, {
					id: 5,
					value: '中医理疗',
					label: '中医理疗'
				}, {
					id: 1,
					value: '母婴护理',
					label: '母婴护理'
				}, {
					id: 7,
					value: '推拿按摩',
					label: '推拿按摩'
				}, {
					id: 9,
					value: '检测服务',
					label: '检测服务'
				}],
				type: {
					homePicture: {
						txt: '首页',
						bg: `background-image:url(../../../static/img/iden/first.png);`,
						src: '',
						src1: '',
					},
					infoPicture: {
						txt: '详情页',
						bg: `background-image:url(../../../static/img/iden/second.png);`,
						src: '',
						src1: '',
					},
					orderPicture: {
						txt: '延续页',
						bg: `background-image:url(../../../static/img/iden/third.png);`,
						src: '',
						src1: '',
					}
				},
				list: [{
						txt: '执业机构',
						pla: '请输入执业机构',
						value: '',
						value1: '',
					},
					{
						txt: '所属科室',
						pla: '请选择所属科室',
						value: '',
						value1: '',
					},
					{
						txt: '当前职称',
						pla: '请选择当前职称',
						value: '',
						value1: '',
					},
					{
						txt: '工作年限',
						pla: '请选择工作年限',
						value: '',
						value1: '',
					},
					{
						txt: '服务类目',
						pla: '请选择服务类目',
						value: "",
						value1: '',
					},
					{
						txt: '服务出发地址',
						pla: '请选择服务出发地址',
						value: "",
						value1: '',
					},
				],
				nurse: [
					'护士',
				],
				section: [
					'全科', '医美', '母婴'
				],
				demo1: [{
						src: "../../../static/img/iden/1.png",
						style: `color: #3c8eff;`,
						judge: '√',
						txt: "标准拍摄"
					},
					{
						src: "../../../static/img/iden/4.png",
						style: `color: rgba(255, 79, 79, 1);`,
						judge: '×',
						txt: "竖向拍摄"
					},
					{
						src: "../../../static/img/iden/2.png",
						style: `color: rgba(255, 79, 79, 1);`,
						judge: '×',
						txt: "拍摄不全"
					},
					{
						src: "../../../static/img/iden/3.png",
						style: `color: rgba(255, 79, 79, 1);`,
						judge: '×',
						txt: "拍摄模糊"
					},
				],
				demo2: [{
						src: "../../../static/img/iden/notice-one.png",
						style: `color: #3c8eff;`,
						judge: '√',
						txt: "标准拍摄"
					},
					{
						src: "../../../static/img/iden/notice-two.png",
						style: `color: rgba(255, 79, 79, 1);`,
						judge: '×',
						txt: "竖向拍摄"
					},
					{
						src: "../../../static/img/iden/notice-three.png",
						style: `color: rgba(255, 79, 79, 1);`,
						judge: '×',
						txt: "拍摄不全"
					},
					{
						src: "../../../static/img/iden/notice-four.png",
						style: `color: rgba(255, 79, 79, 1);`,
						judge: '×',
						txt: "拍摄模糊"
					},
				],
				result: '',
				nurseId: '',
				timeValue: ''

			}
		},
		onLoad(option) {
			this.select()
			this.showType = this.type
			// 身份认证 或 执业认证方式
			if (option.type) {
				this.tabIndex = Number(option.type)
			}
			uni.$on('departAddress', res => {
				let _this = this;
				_this.list[5].value = res.myaddress;
				_this.data1.departAddress = res.myaddress;
				_this.data1.departAddressCity = res.city;
				console.log('_this.data1.departAddress000', _this.data1.departAddress)
			});
			this.getCurrentDate()


		},

		onShow() {
			let tab = -1
			try {
				tab = uni.getStorageSync('tab')
			} catch (e) {
				console.log('error777777-------', e)
			}

			if (tab == 1) {
				uni.removeStorageSync('tab')
				this.tabIndex = 1
			}
			// console.log(this.$store.state.address,this.$store.state.userInfo.attestStatus,'首页的')
			this.data1.type = this.dataType
			// uni.$on('nurseMechanism', res => {
			// 	let _this = this;
			// 	// console.log(res, '接收的数据是');
			// 	_this.list[0].value = res.address;
			// 	_this.data.hospital = res.address;
			// });

		},
		computed: {
			//tab切换样式
			tabStyle(index) {
				var num = this.tabIndex;
				return function(index) {
					// console.log('index',index,'num',num)
					var style;
					if (num == index) {
						return style = `width: 216rpx;
							background: rgba(255, 255, 255, 0.3);
							border: 2rpx solid rgba(255, 255, 255, 0.3);`
					} else {
						if (index == 0) {
							return style = `margin-right:-14rpx`
						} else {
							return style = `margin-left:-14rpx`
						}
					}
				}
			},
			//年限
			year() {
				let arr = ['大于20年']
				for (let i = 20; i > 0; i--) {
					arr.unshift(i + '年')
				}
				return arr
			},
		},
		watch: {
			tabIndex(newValue, oldValue) {
				let title = newValue == 0 ? '身份认证' : '职业资格认证'
				uni.setNavigationBarTitle({
					title: title
				})
			}
		},
		methods: {
			//提交护工认证
			saveCare: debounce(async function() {
				console.log('提交护工认证');
				if (this.cardSrcBefore == '' || this.cardSrcBack == '') {
					uni.showToast({
						icon: 'none',
						title: '请上传身份证信息'
					})
				} else {
					let idcardJson = this.cardSrcBefore + "," + this.cardSrcBack
					let res = await nurseCheckInfo({
						identity: 2,
						caregiverPicture: this.caregiverPicture,
						idcardJson,
						type: 0
					})
					console.log(res, '提交护工信息');
					if (res.object.success) {
						uni.showToast({
							icon: 'none',
							title: '身份审核信息提交成功'
						})
						uni.navigateTo({
							url: '../iden/success'
						})
					}
				}
			}, 2000, true),
			//身份证正面上传
			async idCardBefore() {
				let res = await this.upLoad()
				if (res) {
					this.cardSrcBefore = res
					console.log('111111', this.cardSrcBefore)
					// this.num = 0
					// #ifdef APP-PLUS
					plus.nativeUI.toast('上传成功')
					// #endif
				}
				// else {
				// 	this.num = 1
				// }
			},
			//身份证反面上传
			async idCardBack() {
				console.log(1);
				let res = await this.upLoad()
				if (res) {
					this.cardSrcBack = res
					console.log('111111', this.cardSrcBack)
					// this.num = 0
					// #ifdef APP-PLUS
					plus.nativeUI.toast('上传成功')
					// #endif
				}
				// else {
				// 	this.num = 1
				// }
			},
			//上传护工照片
			async idCareCard() {
				let res = await this.upLoad()
				this.caregiverPicture = res
				console.log(res, '护工证');
			},
			getCurrentDate() {
				var date = new Date()
				var day = date.getDate() + 1
				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				month = (month > 9) ? month : ("0" + month);
				day = (day < 10) ? ("0" + day) : day;
				this.currentDate = year + "-" + month + "-" + day;
			},
			tabChange(index) {
				this.tabIndex = index
				this.data1.type = 0
			},
			//身份证上传
			async idCard() {
				if (this.num < 0) {
					// #ifdef APP-PLUS
					plus.nativeUI.toast('您已完成实名验证')
					// #endif
					// uni.showToast({
					// 	icon:'none',
					// 	title:'您已完成实名验证'
					// })
				} else {
					let res = await this.upLoad()
					if (res) {
						this.cardSrc = res
						console.log('111111', this.cardSrc)
						this.num = 0
						// #ifdef APP-PLUS
						plus.nativeUI.toast('上传成功')
						// #endif
						// uni.showToast({
						// 		icon:'none',
						// 		title:'上传成功！'
						// 	})
					} else {
						this.num = 1
					}
				}

			},
			//认证时未定位跳转定位
			bindBtn(type) {
				if (type == 'confirm') {
					uni.navigateTo({
						url: '../../address/select-address/select-address?atte=true'
					})
				} else {
					uni.navigateBack({
						delta: 1
					})
				}
			},
			//跳转人脸验证
			async moveTo() {
				if (!this.cardSrc) {
					// #ifdef APP-PLUS
					plus.nativeUI.toast('请上传身份证正面照')
					// #endif
					// uni.showToast({
					// 	icon:'none',
					// 	title:'请上传身份证正面照'
					// })
					return
				}
				if (this.num < 0) {
					// #ifdef APP-PLUS
					plus.nativeUI.toast('您已进行过身份验证！')
					// #endif
					// uni.showToast({
					// 	icon:'none',
					// 	title:'您已进行过身份验证！'
					// })
					setTimeout(() => {
						uni.navigateBack({
							delta: 1
						})
						uni.navigateTo({
							url: '../iden/careerChoice'
						})
					})
				} else {
					uni.navigateTo({
						url: "../face-veri/face-veri?cardSrc=" + this.cardSrc
					})
				}

			},
			//职业认证上传护士资格证书
			async nurseFirst() {
				if (this.onData.status == 1 && this.onData.status == 2) {
					this.remind()
				} else {
					let res = await this.upLoad()
					console.log(res, '首页')
					this.data1.nursePicture = res
					console.log(this.data1.nursePicture, '首页')
				}

			},
			//证书类型下的三张图片
			async nursePicture(item) {
				if (this.onData.status == 1 && this.onData.status == 2) {
					this.remind()
				} else {
					let res = await this.upLoad()
					item.src = res
				}

			},
			checkboxChangeSure(e) {
				// console.log(e)
				this.check = e.detail.value.length > 0
			},
			formatDate(d) {
				var date = new Date(d);
				var YY = date.getFullYear() + '-';
				var MM =
					(date.getMonth() + 1 < 10 ?
						'0' + (date.getMonth() + 1) :
						date.getMonth() + 1) + '-';
				var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
				var hh =
					(date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var mm =
					(date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) +
					':';
				var ss =
					date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
				return YY + MM + DD + ' ' + hh + mm + ss;
			},

			//选择证件时间
			changeDatetimePicker(date) {
				this.timeValue = this.formatDate(date.dt)
				console.log('expirationDate', this.data1.expirationDate)
			},
			//证书类型选择
			typeChange(index) {
				this.dataType = index
				this.data1.type = index
				if (index == 0) {
					this.showType = this.type
				} else if (index == 1) {
					delete this.data1.homePicture
					delete this.data1.orderPicture
					this.showType = {}
					this.showType.infoPicture = this.type.infoPicture
				}
				console.log(this.data1.type, index)
			},
			//其他信息列表
			change(index) {
				if (this.onData.status == 2 || this.onData.status == 1) {
					this.remind()
				} else {
					switch (index) {
						case 0:
							// uni.navigateTo({
							// 	url: '../../address/select-address/select-address?type=nurse'
							// })
							break;
						case 1:
							this.$refs.popup.open()
							this.popTitle = "选择所属科室"
							this.popList = 1
							break;
						case 2:
							this.$refs.popup.open()
							this.popTitle = "选择当前职称"
							this.popList = 2
							break;
						case 3:
							this.$refs.popup.open()
							this.popTitle = "选择工作年限"
							this.popList = 3
							break;
						case 4:
							this.$refs.popup.open()
							this.popTitle = "选择服务类目"
							this.popList = 4
							break;
						case 5:
							uni.navigateTo({
								url: '../../address/input-address/index?type=departAddress'
							})
							break;
					}
				}
			},
			//	科室选择
			checkboxChange(event) {
				// console.log(event);
				this.data1.department = event.detail.value
			},
			//职称选择
			radioChange(event) {
				this.data1.position = event.detail.value
			},
			// 类目选择
			itemChange(e) {
				// console.log(e.detail.value, 'eeeee')
				this.itemOptions = this.itemOptions.map(m => {
					m.checked = false
					return m
				})
				this.itemOptions = this.itemOptions.map(m => {
					if (e.detail.value.indexOf(m.value) > -1) {
						m.checked = true
					}
					return m
				})
				this.data1.serviceType = (e.detail.value).join(',')
				this.serviceTypeArr = (e.detail.value).join(',')
			},
			//年限选择
			yearChange(event) {
				this.data1.workingYears = event.detail.value
			},
			//取消按钮 关闭 popup
			popDel() {
				this.$refs.popup.close()
			},
			//popup 确定按钮
			confirm() {
				if (this.popList == 1) {
					this.list[1].value = this.data1.department
				} else if (this.popList == 2) {
					this.list[2].value = this.data1.position
				} else if (this.popList == 3) {
					this.list[3].value = this.data1.workingYears
				} else if (this.popList == 4) {
					this.serviceTypeArr = []
					this.itemOptions.map(m => {
						if (m.checked) {
							this.serviceTypeArr.push(m.value)
						}
					})
					this.list[4].value = this.serviceTypeArr.join(",")
					this.data1.serviceType = this.serviceTypeArr.join(",")
				}
				this.$refs.popup.close()
			},
			//保存执业信息
			save: debounce(async function() {
				console.log('提交方法')
				if (!this.check) {
					plus.nativeUI.toast('请阅读护士上门流程!')
					return
				}
				if (this.data1.type == 0) {
					this.data1.homePicture = this.showType.homePicture.src
					this.data1.infoPicture = this.showType.infoPicture.src
					this.data1.orderPicture = this.showType.orderPicture.src
				} else {
					this.data1.infoPicture = this.showType.infoPicture.src
				}
				this.data1.nurseId = this.nurseId
				let data2 = this.data1

				if (data2.type == 0) {
					console.log('0纸质', data2)
					if (data2.nursePicture == '' || data2.nursePicture == null) {
						uni.showToast({
							icon: 'none',
							title: '请上传护士资格证书'
						})
					} else if (this.timeValue == '') {
						uni.showToast({
							icon: 'none',
							title: '请选择证件截止日期',
						})

					} else if (data2.homePicture == '' || data2.homePicture == null) {
						uni.showToast({
							icon: 'none',
							title: '请上传证书首页'
						})
					} else if (data2.infoPicture == '' || data2.infoPicture == null) {
						uni.showToast({
							icon: 'none',
							title: '请上传证书详情页'
						})
					} else if (data2.orderPicture == '' || data2.orderPicture == null) {
						uni.showToast({
							icon: 'none',
							title: '请上传证书延续页'
						})
					} else if (data2.hospital == '' || data2.hospital == null) {
						uni.showToast({
							icon: 'none',
							title: '请输入执业机构'
						})
					} else if (data2.department == '' || data2.department == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择所属科室'
						})
					} else if (data2.position == '' || data2.position == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择当前职称'
						})
					} else if (data2.workingYears == '' || data2.workingYears == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择工作年限'
						})
					} else if (data2.serviceType == '' || data2.serviceType == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择服务类目'
						})
					} else if (data2.departAddress == '' || data2.departAddress == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择服务出发地址'
						})
					} else {
						data2.expirationDate = this.timeValue
						let res = await nurseCheckInfo(data2)
						if (res.success) {
							// #ifdef APP-PLUS
							plus.nativeUI.toast('提交成功，预计1-3个工作日完成审核！')
							// #endif
							// uni.showToast({
							// 	icon: 'none',
							// 	title: '上传成功,审核中...'
							// })
							setTimeout(() => {
								uni.navigateBack({
									delta: 1
								})
							}, 200)
						}
					}
				}
				if (data2.type == 1) {
					console.log('1电子', data2)
					if (data2.nursePicture == '' || data2.nursePicture == null) {
						uni.showToast({
							icon: 'none',
							title: '请上传护士资格证书'
						})
					} else if (this.timeValue == '') {
						uni.showToast({
							icon: 'none',
							title: '请选择证件截止日期'
						})
					} else if (data2.infoPicture == '' || data2.infoPicture == null) {
						uni.showToast({
							icon: 'none',
							title: '请上传证书详情页'
						})
					} else if (data2.hospital == '' || data2.hospital == null) {
						uni.showToast({
							icon: 'none',
							title: '请输入执业机构'
						})
					} else if (data2.department == '' || data2.department == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择所属科室'
						})
					} else if (data2.position == '' || data2.position == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择当前职称'
						})
					} else if (data2.workingYears == '' || data2.workingYears == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择工作年限'
						})
					} else if (data2.serviceType == '' || data2.serviceType == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择服务类目'
						})
					} else if (data2.departAddress == '' || data2.departAddress == null) {
						uni.showToast({
							icon: 'none',
							title: '请选择服务出发地址'
						})
					} else {
						data2.expirationDate = this.timeValue
						let res = await nurseCheckInfo(data2)
						console.log('1电子0000000', data2)
						if (res.success) {
							// #ifdef APP-PLUS
							plus.nativeUI.toast('提交成功，预计1-3个工作日完成审核！')
							// #endif
							// uni.showToast({
							// 	icon:'none',
							// 	title:'上传成功,审核中...'
							// })

							setTimeout(() => {
								// this.onData.status = 2
								uni.navigateBack({
									delta: 1
								})
							}, 200)
						}
					}
				}
			}, 2000, true),

			// 更新认证信息
			async updateInfo(nurseId) {
				if (this.onData.subStatus == 1) {
					uni.showToast({
						icon: 'none',
						title: '您的护士资格认证正在审核中，请勿重复认证！'
					})
				} else {
					this.tabIndex = 1
					this.onData.status = 0
					this.data1.type = 0
					this.editStatus = 0
					this.$forceUpdate()
				}
			},

			//查询护士认证信息
			async select() {
				let id = this.$store.state.userInfo.id
				console.log('id', id)
				let res = await selectNurseInfoCheckById({
					id
				})
				// console.log('护士信息', res)
				if (res.success) {
					this.onData = res.object
					this.nurseId = this.onData.nurseId

					if (res.object.idcardJson) {
						this.num = -1
						this.cardSrc = res.object.idcardJson
					}
					// // 已拒绝
					// if (res.object.status == 3) {
					// 	// #ifdef APP-PLUS
					// 	plus.nativeUI.toast('您的职业认证未通过，请再次填写提交')
					// 	// #endif
					// 	return
					// }

					this.data1 = res.object
					this.data1.type = res.object.type

					this.list[0].value = res.object.hospital
					this.list[1].value = res.object.department
					this.list[2].value = res.object.position
					this.list[3].value = res.object.workingYears
					this.list[4].value = res.object.serviceType
					this.list[5].value = res.object.departAddress
					this.type.infoPicture.src = res.object.infoPicture
					if (res.object.orderPicture || res.object.homePicture) {
						this.type.orderPicture.src = res.object.orderPicture
						this.type.homePicture.src = res.object.homePicture
					}
					// if (res.object.status == 3) {
					// 	for (k in this.data1) {
					// 		if (!this.data1[k]) {
					// 			delete this.data1[k]
					// 		}
					// 	}
					// 	if (!res.object.homePicture) {
					// 		this.dataType = 1
					// 		this.typeChange(1)
					// 	}
					// 	if (res.object.expirationDate) {
					// 		this.showPicker = res.object.expirationDate
					// 	}

					// }

				}


			},
			//已认证进行的提示
			remind() {
				if (this.onData.subStatus == 1) {
					// #ifdef APP-PLUS
					plus.nativeUI.toast('您的护士资格认证正在审核中，请勿重复认证！')
					// #endif
					// uni.showToast({
					// 	icon:'none',
					// 	title:'您的护士资格认证正在审核中，请勿重复认证！'
					// })
				} else if (this.onData.subStatus == 3) {
					// #ifdef APP-PLUS
					plus.nativeUI.toast('您的护士资格认证未通过，请重新认证!')
					// #endif
					// uni.showToast({
					// 	icon:'none',
					// 	title:'你已进行过护士资格认证，请勿重复认证！'
					// })
				}

			},
			//上传
			upLoad() {
				return new Promise((resolve, reject) => {
					let _this = this
					uni.chooseImage({
						count: 1, //默认9
						sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
						sourceType: ['album', 'camera'], //从相册选择 拍照
						success: function(res) {
							// console.log(res.tempFiles[0].size, '图片尺寸大小是---');
							translateapp(res.tempFilePaths[0], 80, imgUrl => {
								//打印压缩后返回的图片url
								// console.log(imgUrl, '压缩后的路径')
								uploadImage(imgUrl, 'idCardNurse/',
									result => {
										resolve(result)
									}, error => {
										reject(error)
										// #ifdef APP-PLUS
										plus.nativeUI.toast('上传失败')
										// #endif
									})
							})
						},
						fail(e) {
							if (e.errCode == 11) {
								requestAndroid('android.permission.CAMERA', '摄像头')
							}
						}
					})
				})
			},
			nurseNeed() {
				uni.navigateTo({
					url: './flow'
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.update-btn1 {
		height: 40%;
		padding-bottom: 2%;
	}

	.update-btn {
		margin-top: 10%;
		background-color: #508ff6;
		width: 50%;
		height: 90rpx;
		color: #fff;
		font-size: 32rpx;
	}

	.table {
		width: 750rpx;
		height: 108rpx;
		background: #3c8eff;
		display: flex;
		align-items: center;
		padding-left: 24rpx;
		box-sizing: border-box;
	}

	.table view {
		width: 216rpx;
		height: 76rpx;
		border-radius: 38rpx;
		color: #ffffff;
		line-height: 76rpx;
		text-align: center;
		// transition: all 1s;
	}

	.tip {
		width: 100%;
		height: 72rpx;
		background: rgba(255, 106, 0, 0.1);
		// opacity: 0.1;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #ff6a00;
		line-height: 72rpx;
		text-align: center;
	}

	.upload {
		width: 488rpx;
		height: 324rpx;
		margin: 50rpx auto;
		text-align: center;
		background-size: 488rpx 324rpx;
		position: relative;

		.seal {
			width: 128rpx;
			height: 128rpx;
			position: absolute;
			right: 0;
			bottom: -50rpx;
		}
	}

	.upload image {
		width: 488rpx;
		height: 324rpx;
		vertical-align: middle;
		margin-bottom: 48rpx;
	}

	.time {
		width: 90%;
		margin: 0 auto;
		display: flex;
		height: 100rpx;
		align-items: center;
		color: #040506;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);

		.other {
			text-align: right;
			padding-left: 20rpx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			color: #333333;
		}
	}

	.time:active {
		opacity: 0.8;
	}

	.name {
		flex-shrink: 0;
	}

	.value {
		flex: 1;
	}

	.time image {
		width: 48rpx;
		height: 48rpx;
	}

	.zsType {
		justify-content: space-between;
	}

	.type {
		width: 304rpx;
		height: 64rpx;
		display: flex;
		justify-content: space-between;

		.dui {
			width: 20rpx;
			height: 20rpx;
			border-radius: 12rpx 0rpx 12rpx 0rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background-color: #3c8eff;
			position: absolute;
			right: 0;
			bottom: 0;
			box-sizing: border-box;
		}
	}

	.type1 {
		width: 144rpx;
		height: 64rpx;
		border-radius: 16rpx;
		color: rgba(0, 0, 0, 0.38);
		text-align: center;
		line-height: 64rpx;
		border: 2rpx solid rgba(0, 0, 0, 0.1);
	}

	.type2 {
		border: 2rpx solid #3c8eff;
		color: #3c8eff;
		background: #ffffff;
	}

	.pop {
		width: 540rpx;
		height: 620rpx;
		background: #ffffff;
		border-radius: 12rpx;
		position: relative;
	}

	.popTitle {
		width: 540rpx;
		height: 90rpx;
		border-bottom: 1rpx solid #e5e5e5;
		line-height: 90rpx;
		text-align: center;
		font-weight: 400;
		color: #333333;
		font-size: 32rpx;
		box-sizing: border-box;
	}

	.confirm {
		height: 88rpx;
		display: flex;
		overflow: hidden;
		box-sizing: border-box;
		border-top: #e5e5e5 1rpx solid;
		position: absolute;
		left: 0;
		bottom: 0;
	}

	.confirm view {
		width: 270rpx;
		height: 88rpx;
		text-align: center;
		line-height: 88rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		box-sizing: border-box;
	}

	.positive {
		width: 698rpx;
		height: 108rpx;
		background: #ffffff;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
		margin: 0 auto;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(0, 0, 0, 0.87);

		.left {
			width: 8rpx;
			height: 40rpx;
			background: #3c8eff;
			border-radius: 4rpx;
			margin-right: 16rpx;
		}
	}

	.head {
		width: 100%;
		height: 40rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		line-height: 40rpx;
		text-align: center;
		margin-bottom: 40rpx;
	}

	.demo {
		padding-top: 58rpx;
		height: 234rpx;
		width: 100%;
		padding-left: 26rpx;
		padding-right: 36rpx;
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;

		// margin-bottom: 190rpx;
		.demo1 {
			image {
				width: 120rpx;
				height: 120rpx;
			}

			.demo2 {
				width: 120rpx;
				height: 34rpx;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #354052;
				line-height: 34rpx;
			}
		}
	}

	.lose {
		width: 100%;
		height: 532rpx;
		box-sizing: border-box;
		padding-left: 28rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.38);

		// margin-top: 72rpx;
		.loseTip {
			width: 500rpx;
			height: 40rpx;
			display: flex;
			align-items: center;

			.tanhao {
				width: 20rpx;
				height: 20rpx;
				text-align: center;
				line-height: 20rpx;
				background-color: #0055ff;
				margin-right: 10rpx;
			}

			.loseReason {
				width: 364rpx;
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.38);
				line-height: 40rpx;
			}
		}

		.please {
			width: 698rpx;
			height: 112rpx;
			margin-top: 16rpx;
			background: #fafafb;
			padding-left: 32rpx;
			padding-top: 16rpx;
			box-sizing: border-box;
		}
	}

	.into1 {
		margin-top: 190rpx;
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.year {}

	.into {
		width: 100%;
		height: 144rpx;
		background: rgba(216, 216, 216, 0);
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-top: 42rpx;
		box-shadow: 0rpx -6rpx 8rpx 0rpx rgba(0, 0, 0, 0.03);

		&.myinto {
			justify-content: flex-start;
		}

		.save {
			width: 698rpx;
			height: 96rpx;
			line-height: 96rpx;
			text-align: center;
			background: #3c8eff;
			border-radius: 8rpx;
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #ffffff;
		}
	}
</style>